package com.actionscriptclass.state
{
	 import com.actionscriptclass.dataholder.IDataHolder;
	 import com.actionscriptclass.timer.TimerInvoker;
	
    public final class SetState 
	{
		private var _start:IState;
        private var _stop:IState;
        private var _loop:IState; 
        private var _state:IState;
        private var _pause:IState;
        private var _dataHolder:IDataHolder;
        private var _invokerTimer:TimerInvoker;

 
       	public function SetState():void
		{
			
	    }
		
		public function setTimer(timer:TimerInvoker):void
		{
			 _invokerTimer=timer;
             _start= new Start(this,_invokerTimer);
			 _stop = new Stop(this,_invokerTimer);
		     _loop = new Loop(this,_invokerTimer);
		     _pause = new Pause(this,_invokerTimer);
	         setState(_stop);
		}
		
		public function start():void
		{
			  _state.start( );
		}
		
	    public function stop():void
		{
			_state.stop( );
		}
		
		public function loop(loopNumber:uint):void
		{
			_state.loop( loopNumber );
		}
		
		public function pause():void
		{
			_state.pause( );
		}
		
		
		public function setState(state:IState):void
	    {
		   _state=state;
	    }
	    
	    public function getState( ):IState
	    {
		  return _state;
		}
		
		public function getStart( ):IState
		{
		  return  _start;
		}
		
		public function getStop( ):IState
		{
		   return _stop;
		 
		}
		
		public function getLoop( ):IState
		{
		   return _loop;
		}
		
		public function getPause( ):IState
		{
		   return _pause;
		}
        
        //updatng IDataHolder  
		public function setDataHolder(dataHolder:IDataHolder):void
        {
           _dataHolder=dataHolder
        }
        
        //updatng IDataHolder        
        public function setDataToTimer():void
        {
           _invokerTimer.addFunctions(_dataHolder);
        }
       
        //adding new data       
        public function setData(dataObject:Object):void
        {
          _dataHolder.addData(dataObject);
        }       
       

	}
}

